package com.luxuewen.sxa.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.luxuewen.sxa.common.annotation.ApiAuth;
import com.luxuewen.sxa.entity.SxaApis;
import com.luxuewen.sxa.service.impl.SxaApisServiceImpl;
import com.luxuewen.sxa.utils.response.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wen
 */
@RestController
@Slf4j
@Validated
public class ApiController {
    @Autowired
    protected SxaApisServiceImpl sxaApisService;

//    @ApiAuth(alias = "")
    @GetMapping("api/list/by/menu/{menuId}")
    public ApiResponse<List<SxaApis>> listByMenuId (@PathVariable Integer menuId) {
        QueryWrapper<SxaApis> sxaApisQueryWrapper = new QueryWrapper<>();
        sxaApisQueryWrapper.eq("menu_id", menuId).select("id", "menu_id", "name", "alias", "path");
        List<SxaApis> sxaApisList = sxaApisService.list(sxaApisQueryWrapper);

        return ApiResponse.success(sxaApisList);
    }
}
